/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLL;

import DBH.DBHelper;
import com.sun.org.glassfish.external.statistics.Statistic;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JOptionPane;
/**
 *
 * @author Cun_con_yeu_em
 */
public class B_dondathang {
    private DBHelper obj = new DBHelper();
    private String iddathang;
    private String idsp;
    private String tensanpham;
    private int soluong;
    private String giatien;

    /**
     * @return the iddathang
     */
    
     public B_dondathang() {};
    public B_dondathang(String iddathang,String idsp,String tensanpham,int soluong,String giatien) {
        this.iddathang = iddathang;
        this.idsp = idsp;
        this.tensanpham = tensanpham;
        this.soluong = soluong;
        this.giatien = giatien;
        }
    public  Vector getDondathangid(String id) throws SQLException
    {
        Vector v = new Vector();
        Vector paramList=new Vector();
        paramList.add(id);               
        try 
        {
            ResultSet rs = DBHelper.executeQuery("sp_getDondathangid",paramList);
            while(rs.next())
            {                  
               B_dondathang b = new B_dondathang();
                b.setIddathang(rs.getString(1));
                b.setIdsp(rs.getString(2));
                b.setTensanpham(rs.getString(3));
                b.setSoluong(rs.getInt(4));
                b.setGiatien(rs.getString(5));
                v.add(b);                        
            }
        } 
        catch(SQLException sqle) 
        {            
        }
        return v;        
    }
    
      public int insertdondathang(B_dondathang k) throws SQLException {
        
        int i = 0;
        try 
        {
         Vector v = new Vector();
         v.add(k.getIddathang());
         v.add(k.getIdsp());
         v.add(k.getTensanpham());
         v.add(k.getSoluong());
         v.add(k.getGiatien());
        i= DBHelper.executeUpdate("sp_insertDondathang", v) ;
        }
        catch (SQLException e)
        {
        }
        return i;
        }
    public String getIddathang() {
        return iddathang;
    }

    /**
     * @param iddathang the iddathang to set
     */
    public void setIddathang(String iddathang) {
        this.iddathang = iddathang;
    }

    /**
     * @return the idsp
     */
    public String getIdsp() {
        return idsp;
    }

    /**
     * @param idsp the idsp to set
     */
    public void setIdsp(String idsp) {
        this.idsp = idsp;
    }

    /**
     * @return the tensanpham
     */
    public String getTensanpham() {
        return tensanpham;
    }

    /**
     * @param tensanpham the tensanpham to set
     */
    public void setTensanpham(String tensanpham) {
        this.tensanpham = tensanpham;
    }

    /**
     * @return the soluong
     */
    public int getSoluong() {
        return soluong;
    }

    /**
     * @param soluong the soluong to set
     */
    public void setSoluong(int soluong) {
        this.soluong = soluong;
    }

    /**
     * @return the giatien
     */
    public String getGiatien() {
        return giatien;
    }

    /**
     * @param giatien the giatien to set
     */
    public void setGiatien(String giatien) {
        this.giatien = giatien;
    }
    
}
